package com.kexio.file.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * 文件服务配置属性
 * 
 * @author kexio
 */
@ConfigurationProperties(prefix = "kexio.file")
public class FileServiceProperties {

    /**
     * 默认存储类型
     */
    private String defaultStorage = "local";

    /**
     * 是否启用文件秒传
     */
    private boolean enableInstantUpload = true;

    /**
     * 最大文件大小（字节）
     */
    private long maxFileSize = 104857600L; // 100MB

    /**
     * 支持的文件类型（逗号分隔）
     */
    private String allowedFileTypes = "jpg,jpeg,png,gif,bmp,pdf,doc,docx,xls,xlsx,ppt,pptx,txt,zip,rar";

    /**
     * 本地存储配置
     */
    private LocalProperties local = new LocalProperties();

    /**
     * MinIO配置
     */
    private MinioProperties minio = new MinioProperties();

    /**
     * 阿里云OSS配置
     */
    private AliyunOssProperties aliyunOss = new AliyunOssProperties();

    /**
     * 腾讯云COS配置
     */
    private TencentCosProperties tencentCos = new TencentCosProperties();

    /**
     * 七牛云配置
     */
    private QiniuProperties qiniu = new QiniuProperties();

    // ==================== Getter/Setter ====================

    public String getDefaultStorage() { return defaultStorage; }
    public void setDefaultStorage(String defaultStorage) { this.defaultStorage = defaultStorage; }

    public boolean isEnableInstantUpload() { return enableInstantUpload; }
    public void setEnableInstantUpload(boolean enableInstantUpload) { this.enableInstantUpload = enableInstantUpload; }

    public long getMaxFileSize() { return maxFileSize; }
    public void setMaxFileSize(long maxFileSize) { this.maxFileSize = maxFileSize; }

    public String getAllowedFileTypes() { return allowedFileTypes; }
    public void setAllowedFileTypes(String allowedFileTypes) { this.allowedFileTypes = allowedFileTypes; }

    public LocalProperties getLocal() { return local; }
    public void setLocal(LocalProperties local) { this.local = local; }

    public MinioProperties getMinio() { return minio; }
    public void setMinio(MinioProperties minio) { this.minio = minio; }

    public AliyunOssProperties getAliyunOss() { return aliyunOss; }
    public void setAliyunOss(AliyunOssProperties aliyunOss) { this.aliyunOss = aliyunOss; }

    public TencentCosProperties getTencentCos() { return tencentCos; }
    public void setTencentCos(TencentCosProperties tencentCos) { this.tencentCos = tencentCos; }

    public QiniuProperties getQiniu() { return qiniu; }
    public void setQiniu(QiniuProperties qiniu) { this.qiniu = qiniu; }

    // ==================== 内部配置类 ====================

    public static class LocalProperties {
        private String basePath = "/data/files";
        private String urlPrefix = "http://localhost:8080/api/files";

        public String getBasePath() { return basePath; }
        public void setBasePath(String basePath) { this.basePath = basePath; }

        public String getUrlPrefix() { return urlPrefix; }
        public void setUrlPrefix(String urlPrefix) { this.urlPrefix = urlPrefix; }
    }

    public static class MinioProperties {
        private boolean enabled = false;
        private String endpoint;
        private String accessKey;
        private String secretKey;
        private String bucketName;
        private String region = "us-east-1";

        public boolean isEnabled() { return enabled; }
        public void setEnabled(boolean enabled) { this.enabled = enabled; }

        public String getEndpoint() { return endpoint; }
        public void setEndpoint(String endpoint) { this.endpoint = endpoint; }

        public String getAccessKey() { return accessKey; }
        public void setAccessKey(String accessKey) { this.accessKey = accessKey; }

        public String getSecretKey() { return secretKey; }
        public void setSecretKey(String secretKey) { this.secretKey = secretKey; }

        public String getBucketName() { return bucketName; }
        public void setBucketName(String bucketName) { this.bucketName = bucketName; }

        public String getRegion() { return region; }
        public void setRegion(String region) { this.region = region; }
    }

    public static class AliyunOssProperties {
        private boolean enabled = false;
        private String endpoint;
        private String accessKeyId;
        private String accessKeySecret;
        private String bucketName;
        private String domain;

        public boolean isEnabled() { return enabled; }
        public void setEnabled(boolean enabled) { this.enabled = enabled; }

        public String getEndpoint() { return endpoint; }
        public void setEndpoint(String endpoint) { this.endpoint = endpoint; }

        public String getAccessKeyId() { return accessKeyId; }
        public void setAccessKeyId(String accessKeyId) { this.accessKeyId = accessKeyId; }

        public String getAccessKeySecret() { return accessKeySecret; }
        public void setAccessKeySecret(String accessKeySecret) { this.accessKeySecret = accessKeySecret; }

        public String getBucketName() { return bucketName; }
        public void setBucketName(String bucketName) { this.bucketName = bucketName; }

        public String getDomain() { return domain; }
        public void setDomain(String domain) { this.domain = domain; }
    }

    public static class TencentCosProperties {
        private boolean enabled = false;
        private String secretId;
        private String secretKey;
        private String region;
        private String bucketName;
        private String domain;

        public boolean isEnabled() { return enabled; }
        public void setEnabled(boolean enabled) { this.enabled = enabled; }

        public String getSecretId() { return secretId; }
        public void setSecretId(String secretId) { this.secretId = secretId; }

        public String getSecretKey() { return secretKey; }
        public void setSecretKey(String secretKey) { this.secretKey = secretKey; }

        public String getRegion() { return region; }
        public void setRegion(String region) { this.region = region; }

        public String getBucketName() { return bucketName; }
        public void setBucketName(String bucketName) { this.bucketName = bucketName; }

        public String getDomain() { return domain; }
        public void setDomain(String domain) { this.domain = domain; }
    }

    public static class QiniuProperties {
        private boolean enabled = false;
        private String accessKey;
        private String secretKey;
        private String bucket;
        private String domain;
        private String region;

        public boolean isEnabled() { return enabled; }
        public void setEnabled(boolean enabled) { this.enabled = enabled; }

        public String getAccessKey() { return accessKey; }
        public void setAccessKey(String accessKey) { this.accessKey = accessKey; }

        public String getSecretKey() { return secretKey; }
        public void setSecretKey(String secretKey) { this.secretKey = secretKey; }

        public String getBucket() { return bucket; }
        public void setBucket(String bucket) { this.bucket = bucket; }

        public String getDomain() { return domain; }
        public void setDomain(String domain) { this.domain = domain; }

        public String getRegion() { return region; }
        public void setRegion(String region) { this.region = region; }
    }
}
